from django.db import models

# Create your models here.

# 继承model类，变成模型类
class User(models.Model):  # 模型类名，相当于表名
    # 设置属性id(相当于字段),设置自增长(AutoField)和主键约束(primary_key)
    id = models.AutoField(primary_key=True)
    # CharField(字符串类型), max_length(最长长度)
    name = models.CharField(max_length=30)
    # IntegerField(整数类型)
    age = models.IntegerField()

    # 查询数据，按照指定形式进行展示
    def __str__(self):
        return f"User<id={self.id},name={self.name},age={self.age}>"